home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / util / dir / VisualShell117.lha / src / vars.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  14.6 KB  |  427 lines

  1.             /*********************************
  2.          *                               *
  3.          *   Visual Shell v1.17  10/92   *
  4.          *                               *
  5.          *     by Torsten Jürgeleit      *
  6.          *                               *
  7.          *           variables           *
  8.          *                               *
  9.          *********************************/
  10.  
  11.     /* Includes */
  12.  
  13. #include "includes.h"
  14.  
  15.     /* Globals */
  16.  
  17. struct ArpBase               *ArpBase;
  18. struct GfxBase               *GfxBase;
  19. struct IntuitionBase         *IntuitionBase;
  20. struct Process               *_parent_proc;
  21. struct Device              *con_device;
  22. struct ConUnit              *con_unit;
  23. struct Window             *con_window;
  24. struct RastPort             *con_rport;
  25. struct FileHandle         *con_input_fhandle;
  26. struct FileHandle         *con_output_fhandle;
  27. struct TextFont             *con_font;
  28. struct Task             *main_task;
  29. struct MsgPort             *vsh_port;
  30. struct CommandLineInterface  *save_cli;
  31. struct IOStdReq             *input_req;
  32. struct Interrupt         interrupt;
  33. struct FileRequest         file_req[2];
  34. struct ViewRequest         view_req;
  35. struct HistoryRequest         history_req;
  36. struct TreeRequest         tree_req;
  37. struct FileInfoBlock         *fib;
  38. struct InfoData             *idata;
  39. struct TextFont             *old_wb_font;
  40. struct Gadget             gadget;
  41. struct IntuiText         gadget_text;
  42. struct StringInfo         gadget_info;
  43. struct DateTime             date_time;
  44.  
  45. struct TextAttr     con_font_attr, topaz80 = { (STRPTR)"topaz.font",
  46.                      TOPAZ_EIGHTY, FS_NORMAL, FPF_ROMFONT };
  47. struct ConfigEntry  config_entry[MAX_CONFIG_ENTRIES] = {
  48.     { "Left edge (0..n)", LONGINT, 4, 0, 0 },
  49.     { "Top edge (0..n)", LONGINT, 4, 0, 0 },
  50.     { "Width (640..n)", LONGINT, 4, MIN_VSH_WIDTH, 0 },
  51.     { "Height (200..n)", LONGINT, 4, MIN_VSH_HEIGHT, 0 },
  52.     { "Number of CLI lines (1..n)", LONGINT, 2, 1, 0 },
  53.     { "Scroll speed (1..3)", LONGINT, 1, 1, 3 },
  54.     { "Keyboard type (1..2)", LONGINT, 1, 1, 2 },
  55.     { "Dump mode (1..3)", LONGINT, 1, 1, 3 },
  56.     { "Path for editor (e.g. c:ED)", 0, MAX_EDITOR_NAME_LEN, 0, 0 },
  57.     { "Options for editor (e.g. STICKY)", 0, MAX_EDITOR_OPTS_LEN, 0, }
  58. };
  59. UBYTE special_chars[MAX_SPECIAL_CHARS][8] = {
  60.     { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00 },   /* char 128 */
  61.     { 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c },   /* char 129 */
  62.     { 0x00, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x3c, 0x3c },   /* char 130 */
  63.     { 0x3c, 0x3c, 0x3c, 0x3f, 0x3f, 0x3c, 0x3c, 0x3c },   /* char 131 */
  64.     { 0x3c, 0x3c, 0x3c, 0x3f, 0x3f, 0x00, 0x00, 0x00 }    /* char 132 */
  65. };
  66. BYTE *fkey_text[MAX_FKEY_MODES - 1][MAX_FKEYS] = {
  67.       { "      ", "      ", "      ", "      ", "      ", "      ", "      ",
  68.     "      ", "      ", "      " },   /* mode : none */
  69.  
  70.       { "Hide  ", "DupReq", "View  ", "Edit  ", "Copy  ", "RenMov", "MkDir ",
  71.     "Delete", "Histry", "Quit  " },   /* mode : normal */
  72.  
  73.       { "DevAsn", "Info  ", "QView ", "Find  ", "Tree  ", "Pattrn", "CmpDir",
  74.     "      ", "      ", "      " },   /* mode : shift down normal */
  75.  
  76.       { "Normal", "Info  ", "QView ", "Find  ", "Tree  ", "Pattrn", "CmpDir",
  77.     "      ", "      ", "      " },   /* mode : shift down devicess & assign */
  78.  
  79.       { "DevAsn", "Normal", "QView ", "Find  ", "Tree  ", "Pattrn", "CmpDir",
  80.     "      ", "      ", "      " },   /* mode : shift down info */
  81.  
  82.       { "DevAsn", "Info  ", "Normal", "Find  ", "Tree  ", "Pattrn", "CmpDir",
  83.     "      ", "      ", "      " },   /* mode : shift down quick view */
  84.  
  85.       { "DevAsn", "Info  ", "QView ", "Normal", "Tree  ", "Pattrn", "CmpDir",
  86.     "      ", "      ", "      " },   /* mode : shift down find */
  87.  
  88.       { "Show  ", "      ", "      ", "      ", "      ", "      ", "      ",
  89.     "      ", "      ", "Quit  " },   /* mode : hidden */
  90.  
  91.       { "      ", "      ", "      ", "      ", "      ", "      ", "      ",
  92.     "      ", "      ", "Quit  " },   /* mode : quit only */
  93.  
  94.       { "Jump  ", "Search", "Cont  ", "Hex   ", "PrtPg ", "PrtAll", "      ",
  95.     "      ", "      ", "Quit  " },   /* mode : view ascii */
  96.  
  97.       { "Jump  ", "Search", "Cont  ", "ASCII ", "PrtPg ", "PrtAll", "      ",
  98.     "      ", "      ", "Quit  " },   /* mode : view hex */
  99.  
  100.       { "Jump  ", "Search", "Cont  ", "PrtPg ", "PrtAll", "      ", "      ",
  101.     "      ", "      ", "Quit  " },   /* mode : history */
  102.  
  103.       { "Load  ", "Save  ", "Dfault", "Use   ", "      ", "      ", "      ",
  104.     "      ", "      ", "Quit  " },   /* mode : config */
  105. };
  106. USHORT key_table[] = {   /* raw key codes */
  107.     /* qualifier keys */
  108.     0x60,    /* left shift */
  109.     0x61,    /* right shift */
  110.     0x63,    /* ctrl */
  111.     0x64,    /* left alt */
  112.     0x65,    /* right alt */
  113.     0x66,    /* left amiga */
  114.     0x67,    /* right amiga */
  115.     /* normal keys */
  116.     0x50,    /* f1 */
  117.     0x51,    /* f2 */
  118.     0x52,    /* f3 */
  119.     0x53,    /* f4 */
  120.     0x54,    /* f5 */
  121.     0x55,    /* f6 */
  122.     0x56,    /* f7 */
  123.     0x57,    /* f8 */
  124.     0x58,    /* f9 */
  125.     0x59,    /* f10 */
  126.     0x42,    /* tab */
  127.     0x5f,    /* help */
  128.     0x45,    /* esc */
  129.     0x44,    /* return */
  130.     0x0f,    /* numeric pad : 0 */
  131.     0x1d,    /* numeric pad : 1 */
  132.     0x1e,    /* numeric pad : 2 */
  133.     0x1f,    /* numeric pad : 3 */
  134.     0x2d,    /* numeric pad : 4 */
  135.     0x2e,    /* numeric pad : 5 */
  136.     0x2f,    /* numeric pad : 6 */
  137.     0x3d,    /* numeric pad : 7 */
  138.     0x3e,    /* numeric pad : 8 */
  139.     0x3f,    /* numeric pad : 9 */
  140.     0x5a,    /* numeric pad : left braket */
  141.     0x5b,    /* numeric pad : right braket */
  142.     0x5c,    /* numeric pad : slash */
  143.     0x5d,    /* numeric pad : asteriks */
  144.     0x4a,    /* numeric pad : minus */
  145.     0x5e,    /* numeric pad : plus */
  146.     0x43,    /* numeric pad : enter */
  147.     0x3c,    /* numeric pad : point */
  148. };
  149. UBYTE action_table[] = {
  150.     /* qualifier bits */
  151.     QUALIFIERB_SHIFT,
  152.     QUALIFIERB_SHIFT,
  153.     QUALIFIERB_CTRL,
  154.     QUALIFIERB_ALT,
  155.     QUALIFIERB_ALT,
  156.     QUALIFIERB_AMIGA,
  157.     QUALIFIERB_AMIGA,
  158.     /* action codes */
  159.     VSH_ACTION_F1,
  160.     VSH_ACTION_F2,
  161.     VSH_ACTION_F3,
  162.     VSH_ACTION_F4,
  163.     VSH_ACTION_F5,
  164.     VSH_ACTION_F6,
  165.     VSH_ACTION_F7,
  166.     VSH_ACTION_F8,
  167.     VSH_ACTION_F9,
  168.     VSH_ACTION_F10,
  169.     VSH_ACTION_TAB,
  170.     VSH_ACTION_HELP,
  171.     VSH_ACTION_ESC,
  172.     VSH_ACTION_RETURN,
  173.     VSH_ACTION_NUM_0,
  174.     VSH_ACTION_NUM_1,
  175.     VSH_ACTION_NUM_2,
  176.     VSH_ACTION_NUM_3,
  177.     VSH_ACTION_NUM_4,
  178.     VSH_ACTION_NUM_5,
  179.     VSH_ACTION_NUM_6,
  180.     VSH_ACTION_NUM_7,
  181.     VSH_ACTION_NUM_8,
  182.     VSH_ACTION_NUM_9,
  183.     VSH_ACTION_NUM_LEFT_BRAKET,
  184.     VSH_ACTION_NUM_RIGHT_BRAKET,
  185.     VSH_ACTION_NUM_SLASH,
  186.     VSH_ACTION_NUM_ASTERIKS,
  187.     VSH_ACTION_NUM_MINUS,
  188.     VSH_ACTION_NUM_PLUS,
  189.     VSH_ACTION_NUM_ENTER,
  190.     VSH_ACTION_NUM_POINT,
  191. };
  192. UBYTE scroll_flag_table[] = {
  193.     0x81,    /* scroll top */
  194.     0x82,    /* scroll bottom */
  195.     0x41,    /* scroll page up */
  196.     0x42,    /* scroll page down */
  197.     0x01,    /* scroll up */
  198.     0x02,    /* scroll down */
  199.     0x04,    /* scroll left */
  200.     0x08    /* scroll right */
  201. };
  202. BYTE *status_text[] = {
  203.     "Reading directory ...",
  204.     "Duplicating file requester ...",
  205.     "Reading devices and assigns ...",
  206.     "Reading file ...",
  207.     "Building line list ...",
  208.     "Releasing line list ...",
  209.     "Running file ...",
  210.     "Editing file ...",
  211.     "Inserting file name at current cursor position ...",
  212.     "Changing view mode ...",
  213.     "Executing user function ...",
  214.     "Printing text ... (ESC to abort)",
  215.     "Making new directory ...",
  216.     "Releasing directory tree",
  217.     "ConMan command line history",
  218.     "Executing history line ...",
  219.     "Executing script file ...",
  220.     "Comparing directories ..."
  221. };
  222. BYTE *error_text[] = {
  223.     "Out of memory !",
  224.     "No directory !",
  225.     "No load file !",
  226.     "Lock() failed !",
  227.     "Open() failed !",
  228.     "Read() failed !",
  229.     "Write() failed !",
  230.     "Seek() failed !",
  231.     "Examine() failed !",
  232.     "ExNext() failed !",
  233.     "ParentDir() failed !",
  234.     "Info() failed !",
  235.     "FindFirst() or FindNext() failed !",
  236.     "SyncRun() failed !",
  237.     "Execute() failed - perhaps no c:Run !",
  238.     "Rename() failed !",
  239.     "CreateDir() failed !",
  240.     "DeleteFile() failed !",
  241.     "SetProtection() failed !",
  242.     "SetComment() failed !",
  243.     "SetDate() failed !",
  244.     "Search failed !",
  245.     "Directory not found !",
  246.     "Can't find CLI !",
  247.     "Only valid for ConMan v1.3 or higher !",
  248.     "Can't access editor !",
  249.     "Editor no load file !",
  250.     "Can't build path name !",
  251.     "Can't open PRT: !",
  252.     "Printing text failed !",
  253.     "Missing second quote in user function !",
  254.     "No file name specified !",
  255.     "Empty file selected !",
  256.     "Can't access source !",
  257.     "Can't access destination !",
  258.     "Object not found !",
  259.     "Object in use !",
  260.     "Object already exists !",
  261.     "Object of wrong type !",
  262.     "Directory name already used by a file!",
  263.     "Disk write protected !",
  264.     "Disk not validated !",
  265.     "Disk full !",
  266.     "No disk in drive !",
  267.     "Not a DOS disk in drive !",
  268.     "Invalid pattern !",
  269.     "Can't copy object onto itself !",
  270.     "Multiple copy only to directory !",
  271.     "Can't rename/move entry onto itself !",
  272.     "Multiple rename/move only to directory !",
  273.     "Can't rename object across devices !",
  274.     "Aborted !",
  275.     "Invalid line number !",
  276.     "Invalid hex number !",
  277.     "Different directory modes !",
  278.     "Read protection flag set !",
  279.     "Write protection flag set !",
  280.     "Execute protection flag set !",
  281.     "Delete protection flag set !",
  282.     NULL,   /* no msg for skipped error */
  283.     "Not enough memory for copy buffer !",
  284.     "Directory not empty !"
  285. };
  286. BYTE *prompt_line[] = {
  287.     "3Press <ENTER> or <F10> for next page or continue !",
  288.     "3Press <ENTER>, <Shift ENTER> or <F10> for next/previous page or continue !",
  289.     "3Press <Shift ENTER> or <F10> for previous page or continue !",
  290.     "3Press <ENTER> or <F10> to continue !"
  291. };
  292. BYTE *about_line[MAX_ABOUT_LINES] = {
  293.     "3Visual Shell (VSh) v1.17",
  294.     (BYTE *)-1L,
  295.     "1© Copyright 1992, Freeware, All rights reserved",
  296.     NULL,
  297.     "1written by Torsten Jürgeleit    ",
  298.     "1           Am Sandberg 4        ",
  299.     "1           W-5270 Gummersbach   ",
  300.     "1           Germany              ",
  301.     "1           Phone ++49 2261 27400",
  302.     NULL,
  303.     "1Thanks to the ARP authors for their great ARP library",
  304.     "1and William S. Hawes for his wonderful ConMan !",
  305.     NULL,
  306.     "1Press HELP for some informations about VSh commands !"
  307. };
  308. BYTE *help_line[] = {
  309.     "HDescription of function keys for Main :",
  310.     "3F1  = toggle display mode (Hide = hide file requesters)",
  311.     "3F2  = duplicate active filerequester to nonactive one",
  312.     "3F3  = view selected file as ASCII or hex dump",
  313.     "3F4  = edit selected file",
  314.     "3F5  = copy marked files from active to nonactive file requester",
  315.     "3F6  = move or rename marked files from active to nonactive freq",
  316.     "3F7  = make new directory in active file requester",
  317.     "3F8  = delete marked files from active file requester",
  318.     "3F9  = show ConMan command line history",
  319.     "3F10 = quit VSh",
  320.     "3F11 = show devices, assigns and volumes in active file req",
  321.     "3F12 = show infos about other file requester in active one",
  322.     "3F13 = show contents of selected file in active file requester",
  323.     "3F14 = search file by pattern, start from path in active file req",
  324.     "3F15 = new filter pattern for active file requester",
  325.     "3F16 = build directory tree for device in active file requester",
  326.     "3F17 = compare contents of both file requesters",
  327.     "3ALT F1",
  328.     "4  :    = user defined functions",
  329.     "3ALT F10",
  330.     "3ALT SHIFT F1  = change user defined functions, special symbols :",
  331.     "4     :         '[]' -> insert selected file name at this position",
  332.     "3ALT SHIFT F10   ';'  -> delimiter for function key name (max. 6 chars)",
  333.  
  334.     "HDescription of function keys for View :",
  335.     "3F1  = jump to line specified by number",
  336.     "3F2  = search string in file (hex string with a leading $)",
  337.     "3F3  = continue searching with same search string",
  338.     "3F4  = toggle view mode (ASCII or hex dump)",
  339.     "3F5  = send current page to printer",
  340.     "3F6  = send whole text to printer",
  341.     "3F10 = quit view",
  342.  
  343.     "HDescription of function keys for History :",
  344.     "3F1  = jump to line specified by number",
  345.     "3F2  = search string in history",
  346.     "3F3  = continue searching with same search string",
  347.     "3F4  = send current page to printer",
  348.     "3F5  = send whole history to printer",
  349.     "3F10 = quit history",
  350.  
  351.     "HDescription of function keys for Configuration :",
  352.     "3F1  = load old configuration file 's:VSh.Config'",
  353.     "3F2  = save new configuration file 's:VSh.Config'",
  354.     "3F3  = use default configuration",
  355.     "3F4  = use selected configuration",
  356.     "3F10 = quit configuration",
  357.  
  358.     "HDescription of numeric pad keys :",
  359.     "31       = move cursor in file list to bottom of list",
  360.     "32       = move cursor in file list down by one entry",
  361.     "33       = move cursor in file list down by one page",
  362.     "34       = read parent directory",
  363.     "3SHIFT 4 = read root directory",
  364.     "35       = read current directory once again",
  365.     "36       = read directory under cursor",
  366.     "3SHIFT 6 = read directory under cursor to nonactive file requester",
  367.     "37       = move cursor in file list to top of list",
  368.     "38       = move cursor in file list up by one entry",
  369.     "39       = move cursor in file list up by one page",
  370.     "30       = mark or unmark selected entry in active file requester",
  371.     "3SHIFT 0 = unmark all selected entries",
  372.     "3.       = insert file name in command line",
  373.     "3SHIFT . = insert file name with full path in command line",
  374.     "K13-       = select entries to mark by pattern (* = mark all)",
  375.     "K23+       = select entries to mark by pattern (* = mark all)",
  376.     "K13SHIFT - = select entries to unmark by pattern (* = unmark all)",
  377.     "K23-       = select entries to unmark by pattern (* = unmark all)",
  378.     "K13ALT -   = toggle num lock for normal numeric key pad",
  379.     "K23[       = toggle num lock for normal numeric key pad",
  380.     "3ENTER   = run file, execute script or enter dir under cursor",
  381.  
  382.     "HDescription of other keys :",
  383.     "3TAB            = toggle active file requester",
  384.     "3HELP           = show this help pages",
  385.     "3SHIFT HELP     = show about page",
  386.     "3SHIFT ALT HELP = change configuration",
  387.     "3ALT [any key]  = speed search",
  388.     "3ESC            = quit any function",
  389.  
  390.     NULL
  391. };
  392.  
  393. BYTE   gadget_buffer[MAX_GADGET_BUFFER_LEN + 1],
  394.        day_buffer[LEN_DATSTRING + 1],
  395.        date_buffer[LEN_DATSTRING + 1],
  396.        time_buffer[LEN_DATSTRING + 1];
  397. BYTE   process_name[MAX_PROCESS_NAME_LEN + 1];
  398. UBYTE  *font_data, *template_buffer;
  399. BYTE   *cursor_off = "\x1b[H\x1b[0 p\n", *cursor_on = "\x1b[H\x1b[ p",
  400.        *protection_bits = PROTECTION_BITS, *nil = "NIL:", *star = "*",
  401.        *empty = "";
  402. BYTE   *dir_arg[2], *user_fkey_text[MAX_FKEYS],
  403.        *user_function[MAX_USER_FUNCTIONS];
  404. BPTR   con_handle, nil_handle;
  405. BYTE   path1_buffer[MAX_PATH_NAME_LEN + 1],
  406.        path2_buffer[MAX_PATH_NAME_LEN + 1],
  407.        file1_buffer[MAX_FILE_NAME_LEN + 1],
  408.        file2_buffer[MAX_FILE_NAME_LEN + 1],
  409.        line1_buffer[MAX_LINE_LEN + 1],
  410.        line2_buffer[MAX_LINE_LEN + 1],
  411.        status_fmt[60],
  412.        standard_fmt[6],
  413.        protection_string[MAX_PROTECTION_BITS + 1];
  414. UBYTE  event_mode, action, auto_repeat, active_freq, scroll_flag, show_flag,
  415.        num_lock, qualifier, enable_abort, wshell_flag, delayed_cd;
  416. SHORT  status, status_delay, error_delay;
  417. UBYTE  old_bleft, old_btop, old_bright, old_bbottom;
  418. USHORT old_left, old_top, old_width, old_height, old_min_width,
  419.        old_min_height, old_max_width, old_max_height;
  420. ULONG  old_flags, old_idcmp_flags;
  421. USHORT vsh_left, vsh_top, vsh_width, vsh_height, vsh_cli_lines;
  422. UBYTE  vsh_scroll_speed, vsh_keyboard_type, vsh_dump_mode;
  423. BYTE   *vsh_config_file = VSH_CONFIG_FILE, *vsh_editor_name,
  424.        *vsh_editor_opts;
  425. USHORT wb_width, wb_height, wb_line_len, max_line_len, max_dir_name_len,
  426.        cli_vpos, fkey_dist, fkey_left, last1_answer, last2_answer;
  427.